#include "Stdafx.h"
#include "DumpGlobal.h"

//////////////////////////////////////////////////////////////////////////
class DumpGlobalPrivate
{
	Q_DECLARE_PUBLIC(DumpGlobal)

public:
	DumpGlobalPrivate()
		: m_hInst(NULL)
	{
		memset(m_szModule, 0, sizeof(m_szModule));
		memset(m_szAppName, 0, sizeof(m_szAppName));
		memset(m_szLogPath, 0, sizeof(m_szLogPath));
		memset(m_szResPath, 0, sizeof(m_szResPath));
	};
	virtual ~DumpGlobalPrivate() {};

	void init() {};

protected:
	DumpGlobal *q_ptr;
	// 
	HINSTANCE m_hInst;
	wchar_t	m_szModule[DUMPUTIL_STR_LENGTH];
	wchar_t m_szAppName[DUMPUTIL_STR_LENGTH];
	wchar_t m_szLogPath[DUMPUTIL_STR_LENGTH];
	wchar_t m_szResPath[DUMPUTIL_STR_LENGTH];
};
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
DumpGlobal::DumpGlobal()
	: d_ptr(new DumpGlobalPrivate)
{
	d_ptr->q_ptr = this;
	d_func()->init();
}

DumpGlobal::~DumpGlobal()
{
	SAFE_DELETE(d_ptr);
}

HINSTANCE DumpGlobal::Inst() const
{
	//Q_D(const DumpGlobal);
	//return d->m_hInst;
	return d_func()->m_hInst;
}

void DumpGlobal::Inst(HINSTANCE val)
{
	//Q_D(DumpGlobal);
	//return d->m_hInst;
	d_func()->m_hInst = val;
}

const wchar_t* DumpGlobal::Module() const
{
	return d_func()->m_szModule;
}

void DumpGlobal::Module(const wchar_t* val)
{
	if(!val)
		return;
	memset(d_func()->m_szModule, 0, DUMPUTIL_STR_LENGTH*sizeof(wchar_t));
	wcscpy_s(d_func()->m_szModule, DUMPUTIL_STR_LENGTH, val);
}

const wchar_t* DumpGlobal::AppName() const
{
	return d_func()->m_szAppName;
}

void DumpGlobal::AppName(const wchar_t* val)
{
	if(!val)
		return;
	memset(d_func()->m_szAppName, 0, DUMPUTIL_STR_LENGTH*sizeof(wchar_t));
	wcscpy_s(d_func()->m_szAppName, DUMPUTIL_STR_LENGTH, val);
};

const wchar_t* DumpGlobal::LogPath() const
{
	return d_func()->m_szLogPath;
}

void DumpGlobal::LogPath(const wchar_t* val)
{
	if(!val)
		return;
	memset(d_func()->m_szLogPath, 0, DUMPUTIL_STR_LENGTH*sizeof(wchar_t));
	wcscpy_s(d_func()->m_szLogPath, DUMPUTIL_STR_LENGTH, val);
};

const wchar_t* DumpGlobal::ResPath() const
{
	return d_func()->m_szResPath;
}

void DumpGlobal::ResPath(const wchar_t* val)
{
	if(!val)
		return;
	memset(d_func()->m_szResPath, 0, DUMPUTIL_STR_LENGTH*sizeof(wchar_t));
	wcscpy_s(d_func()->m_szResPath, DUMPUTIL_STR_LENGTH, val);
};
//////////////////////////////////////////////////////////////////////////